home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / enigma / earcd / emula / arosdv19.lha / AROS / intuition / openwindow.c < prev    next >
C/C++ Source or Header  |  1996-11-08  |  4KB  |  162 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: openwindow.c,v 1.8 1996/11/08 11:28:04 aros Exp $
  4.  
  5.     Desc: Intuition function OpenWindow()
  6.     Lang: english
  7. */
  8. #include "intuition_intern.h"
  9. #include <exec/memory.h>
  10. #include <intuition/intuition.h>
  11. #include <clib/exec_protos.h>
  12. #include <clib/graphics_protos.h>
  13.  
  14. #ifndef DEBUG_OpenWindow
  15. #   define DEBUG_OpenWindow 0
  16. #endif
  17. #if DEBUG_OpenWindow
  18. #   undef DEBUG
  19. #   define DEBUG 1
  20. #endif
  21. #include <aros/debug.h>
  22.  
  23. /*****************************************************************************
  24.  
  25.     NAME */
  26.     #include <intuition/intuition.h>
  27.     #include <clib/intuition_protos.h>
  28.  
  29.     AROS_LH1(struct Window *, OpenWindow,
  30.  
  31. /*  SYNOPSIS */
  32.     AROS_LHA(struct NewWindow *, newWindow, A0),
  33.  
  34. /*  LOCATION */
  35.     struct IntuitionBase *, IntuitionBase, 34, Intuition)
  36.  
  37. /*  FUNCTION
  38.     Opens a new window with the characteristiks specified in
  39.     newWindow.
  40.  
  41.     INPUTS
  42.     newWindow - How you would like your new window.
  43.  
  44.     RESULT
  45.     A pointer to the new window or NULL if it couldn't be
  46.     opened. Reasons for this might be lack of memory or illegal
  47.     attributes.
  48.  
  49.     NOTES
  50.  
  51.     EXAMPLE
  52.  
  53.     BUGS
  54.  
  55.     SEE ALSO
  56.     CloseWindow(), ModifyIDCMP()
  57.  
  58.     INTERNALS
  59.  
  60.     HISTORY
  61.     29-10-95    digulla automatically created from
  62.                 intuition_lib.fd and clib/intuition_protos.h
  63.  
  64. *****************************************************************************/
  65. {
  66.     AROS_LIBFUNC_INIT
  67.     AROS_LIBBASE_EXT_DECL(struct IntuitionBase *,IntuitionBase)
  68.     struct Window * w;
  69.     struct RastPort * rp;
  70.     ULONG lock;
  71.  
  72.     D(bug("OpenWindow (%p = { Left=%d Top=%d Width=%d Height=%d })\n"
  73.     , newWindow
  74.     , newWindow->LeftEdge
  75.     , newWindow->TopEdge
  76.     , newWindow->Width
  77.     , newWindow->Height
  78.     ));
  79.  
  80.     w  = AllocMem (intui_GetWindowSize (), MEMF_CLEAR);
  81.     rp = CreateRastPort ();
  82.  
  83.     if (!w || !rp)
  84.     goto failexit;
  85.  
  86.     if (!ModifyIDCMP (w, newWindow->IDCMPFlags))
  87.     goto failexit;
  88.  
  89.     w->LeftEdge    = newWindow->LeftEdge;
  90.     w->TopEdge       = newWindow->TopEdge;
  91.     w->Width       = newWindow->Width;
  92.     w->Height       = newWindow->Height;
  93.     w->RPort       = rp;
  94.     w->FirstGadget = newWindow->FirstGadget;
  95.  
  96.     if (newWindow->DetailPen == 0xFF) newWindow->DetailPen = 1;
  97.     if (newWindow->BlockPen  == 0xFF) newWindow->BlockPen = 0;
  98.  
  99.     w->BorderLeft   = 0;
  100.     w->BorderTop    = 0;
  101.     w->BorderRight  = 0;
  102.     w->BorderBottom = 0;
  103.  
  104.     w->MinWidth  = newWindow->MinWidth;
  105.     w->MinHeight = newWindow->MinHeight;
  106.     w->MaxWidth  = newWindow->MaxWidth;
  107.     w->MaxHeight = newWindow->MaxHeight;
  108.  
  109.     if (newWindow->Type == PUBLICSCREEN)
  110.     w->WScreen = IntuitionBase->ActiveScreen;
  111.     else if (newWindow->Type == CUSTOMSCREEN)
  112.     w->WScreen = newWindow->Screen;
  113.     else
  114.     w->WScreen = GetPrivIBase (IntuitionBase)->WorkBench;
  115.  
  116.     if (!intui_OpenWindow (w, IntuitionBase))
  117.     goto failexit;
  118.  
  119.     if (w->WScreen->Font)
  120.     SetFont (rp, ((struct IntScreen *)(w->WScreen))->DInfo.dri_Font);
  121.     else
  122.     SetFont (rp, GfxBase->DefaultFont);
  123.  
  124.     SetAPen (rp, newWindow->DetailPen);
  125.     SetBPen (rp, newWindow->BlockPen);
  126.     SetDrMd (rp, JAM2);
  127.  
  128.     SetWindowTitles (w, newWindow->Title, (STRPTR)-1);
  129.  
  130.     lock = LockIBase (0);
  131.  
  132.     w->Parent = NULL;
  133.     w->NextWindow = w->Descendant = w->WScreen->FirstWindow;
  134.     w->WScreen->FirstWindow = w;
  135.  
  136.     if (newWindow->Flags & ACTIVATE)
  137.     IntuitionBase->ActiveWindow = w;
  138.  
  139.     UnlockIBase (lock);
  140.  
  141.     RefreshGadgets (w->FirstGadget, w, NULL);
  142.  
  143.     goto exit;
  144.  
  145. failexit:
  146.     ModifyIDCMP (w, 0L);
  147.  
  148.     if (rp)
  149.     FreeRastPort (rp);
  150.  
  151.     if (w)
  152.     {
  153.     FreeMem (w, intui_GetWindowSize ());
  154.  
  155.     w = NULL;
  156.     }
  157.  
  158. exit:
  159.     ReturnPtr ("OpenWindow", struct Window *, w);
  160.     AROS_LIBFUNC_EXIT
  161. } /* OpenWindow */
  162.